import request from '@/utils/request'
const UpmsPostService = {
  state: {},

  mutations: {},

  actions: {

    // 岗位分页
    postPage({ commit }, params) {
      return new Promise((resolve, reject) => {
        request.get('post/page', params).then(response => {
          resolve(response)
        }).catch(error => {
          reject(error)
        })
      })
    },

    // 岗位保存
    postSave({ commit }, params) {
      return new Promise((resolve, reject) => {
        request.post('post/save', {
          code: params.code,
          name: params.name,
          orders: params.orders,
          type: params.type,
          description: params.description
        }).then(response => {
          resolve(response)
        }).catch(error => {
          reject(error)
        })
      })
    },

    // 岗位更新
    postUpdate({ commit }, params) {
      return new Promise((resolve, reject) => {
        request.post('post/update/' + params.id, {
          code: params.code,
          name: params.name,
          orders: params.orders,
          type: params.type,
          description: params.description
        }).then(response => {
          resolve(response)
        }).catch(error => {
          reject(error)
        })
      })
    },

    // 岗位删除
    postRemove({ commit }, params) {
      return new Promise((resolve, reject) => {
        request.post('post/remove', params).then(response => {
          resolve(response)
        }).catch(error => {
          reject(error)
        })
      })
    },

    // 岗位列表
    postList({ commit }) {
      return new Promise((resolve, reject) => {
        request.get('post/list').then(response => {
          resolve(response)
        }).catch(error => {
          reject(error)
        })
      })
    },

    // 更新岗位状态
    changePostState({ commit }, params) {
      return new Promise((resolve, reject) => {
        request.post('post/changeIsState/' + params.id, params.status).then(response => {
          resolve(response)
        }).catch(error => {
          reject(error)
        })
      })
    }
  }
}

export default UpmsPostService
